<!-- Footer -->
<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                <ul class="list-inline text-center">                  
                    {{ with .Site.Params.social.email }}
                    <li>
                        <a href="mailto:{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fas fa-envelope fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		           {{ end }}
                    {{ with .Site.Params.social.twitter }}
                    <li>
                        <a href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-twitter fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    {{ end }}
                    {{ with .Site.Params.social.zhihu }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab  fa-stack-1x fa-inverse">知</i>
                            </span>
                        </a>
                    </li>
		            {{ end }}
                    {{ with .Site.Params.social.weibo }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-weibo fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		           {{ end }}
                    {{ with .Site.Params.social.facebook }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-facebook fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		           {{ end }}

		            <!-- Huabing: add wechat QR code link -->
                    {{ with .Site.Params.social.wechat }}
                    <li>
                        <a target="_blank" href="{{ . | relURL }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-weixin fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		            {{ end }}
                    {{ with .Site.Params.social.github }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-github fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		            {{ end }}
                    {{ with .Site.Params.social.gitlab }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-gitlab fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    {{ end }}
                    {{ with .Site.Params.social.git }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-git fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    {{ end }}
                    {{ with .Site.Params.social.linkedin }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-linkedin fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		           {{ end }}
                    {{ with .Site.Params.social.medium }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-medium fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    {{ end }}
                    {{ with .Site.Params.social.stackoverflow }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-stack-overflow fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    {{ end }}
                    {{ with .Site.Params.social.reddit }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-reddit fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    {{ end }}
                    {{ with .Site.Params.social.slack }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-slack fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    {{ end }}
                    {{ with .Site.Params.social.mastodon }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-mastodon fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    {{ end }}
                    {{ with .Site.Params.social.keybase }}
                    <li>
                        <a target="_blank" href="{{ . }}">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-keybase fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
            {{ end }}
            {{ with .Site.Params.social.xing }}
            <li>
                <a target="_blank" href="{{ . }}">
                    <span class="fa-stack fa-lg">
                        <i class="fas fa-circle fa-stack-2x"></i>
                        <i class="fab fa-xing fa-stack-1x fa-inverse"></i>
                    </span>
                </a>
            </li>
            {{ end }}
            {{ with .Site.Params.social.instagram }}
            <li>
                <a target="_blank" href="{{ . }}">
                    <span class="fa-stack fa-lg">
                        <i class="fas fa-circle fa-stack-2x"></i>
                        <i class="fab fa-instagram fa-stack-1x fa-inverse"></i>
                    </span>
                </a>
            </li>
            {{ end }}
            {{ with .Site.Params.social.flickr }}
            <li>
                <a target="_blank" href="{{ . }}">
                    <span class="fa-stack fa-lg">
                        <i class="fas fa-circle fa-stack-2x"></i>
                        <i class="fab fa-flickr fa-stack-1x fa-inverse"></i>
                    </span>
                </a>
            </li>
           {{ end }}
           {{ if .Site.Params.social.rss }}
                   <li>
                       <a href='{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}' rel="alternate" type="application/rss+xml" title="{{ .Site.Title | default "" }}" >
                           <span class="fa-stack fa-lg">
                               <i class="fas fa-circle fa-stack-2x"></i>
                               <i class="fas fa-rss fa-stack-1x fa-inverse"></i>
                           </span>
                       </a>
                   </li>
            {{ end }}
             </ul>
		<p class="copyright text-muted">
                    Copyright &copy; {{ .Site.Title }} {{ now.Year }} {{- if .Site.Params.icp }} | {{ with .Site.Params.icp }}{{ . | markdownify }}{{ end }}{{- end}}
                    <br>
                    <a href="https://themes.gohugo.io/hugo-theme-cleanwhite">CleanWhite Hugo Theme</a> by <a href="https://zhaohuabing.com">Huabing</a> |
                    <iframe
                        style="margin-left: 2px; margin-bottom:-5px;"
                        frameborder="0" scrolling="0" width="100px" height="20px"
                        src="https://ghbtns.com/github-btn.html?user=zhaohuabing&repo=hugo-theme-cleanwhite&type=star&count=true" >
                    </iframe>
                </p>
            </div>
        </div>
    </div>
</footer>



<!-- async load function -->
<script>
    function loadAsync(u, c) {
      var d = document, t = 'script',
          o = d.createElement(t),
          s = d.getElementsByTagName(t)[0];
      o.src = u;
      if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
      s.parentNode.insertBefore(o, s);
    }
</script>

<!--
     Because of the native support for backtick-style fenced code blocks
     right within the Markdown is landed in Github Pages,
     From V1.6, There is no need for Highlight.js,
     so Huxblog drops it officially.

     - https://github.com/blog/2100-github-pages-now-faster-and-simpler-with-jekyll-3-0
     - https://help.github.com/articles/creating-and-highlighting-code-blocks/
-->
<!--
    <script>
        loadAsync("http://cdn.bootcss.com/highlight.js/8.6/highlight.min.js", function(){
            hljs.initHighlightingOnLoad();
        })
    </script>
    <link href="http://cdn.bootcss.com/highlight.js/8.6/styles/github.min.css" rel="stylesheet">
-->


<!-- jquery.tagcloud.js -->
<script>
    // only load tagcloud.js in tag.html
    if($('#tag_cloud').length !== 0){
        loadAsync("/js/jquery.tagcloud.js",function(){
            $.fn.tagcloud.defaults = {
                //size: {start: 1, end: 1, unit: 'em'},
                color: {start: '#bbbbee', end: '#0085a1'},
            };
            $('#tag_cloud a').tagcloud();
        })
    }
</script>

<!--fastClick.js -->
<script>
    loadAsync("https://cdn.jsdelivr.net/npm/fastclick@1.0.6/lib/fastclick.min.js", function(){
        var $nav = document.querySelector("nav");
        if($nav) FastClick.attach($nav);
    })
</script>

<!-- push page to Baidu -->
{{ if .Site.Params.ba_track_id }}
<script>
    (function(){
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https'){
       bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      }
      else{
      bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

<!-- Baidu Tongji -->
<script>
    // dynamic User by Hux
    var _baId = '{{ .Site.Params.ba_track_id }}';

    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>
{{ end }}

<!-- Side Catalog -->
{{ if not (eq (.Param "showtoc") false) }}
<script type="text/javascript">
    function generateCatalog(selector) {

        // interop with multilangual
        //if ('page.multilingual' == 'true') {
        //    _containerSelector = 'div.post-container.active'
        //} else {
            _containerSelector = 'div.post-container'
        //}

        // init
        var P = $(_containerSelector), a, n, t, l, i, c;
        a = P.find('h1,h2,h3,h4,h5,h6');

        // clean
        $(selector).html('')

        // appending
        a.each(function () {
            n = $(this).prop('tagName').toLowerCase();
            i = "#" + $(this).prop('id');
            t = $(this).text();
            c = $('<a href="' + i + '" rel="nofollow">' + t + '</a>');
            l = $('<li class="' + n + '_nav"></li>').append(c);
            $(selector).append(l);
        });
        return true;
    }

    generateCatalog(".catalog-body");

    // toggle side catalog
    $(".catalog-toggle").click((function (e) {
        e.preventDefault();
        $('.side-catalog').toggleClass("fold")
    }))

    /*
     * Doc: https://github.com/davist11/jQuery-One-Page-Nav
     * Fork by Hux to support padding
     */

    loadAsync("{{ "js/jquery.nav.js" | relURL }}", function () {
        $('.catalog-body').onePageNav({
            currentClass: "active",
            changeHash: !1,
            easing: "swing",
            filter: "",
            scrollSpeed: 700,
            scrollOffset: 0,
            scrollThreshold: .2,
            begin: null,
            end: null,
            scrollChange: null,
            padding: 80
        });
    });
</script>
{{ end }}

{{ if eq (.Param "multilingual") true }}
<script type="text/javascript">
    // get nodes
    var $zh = document.querySelector(".zh");
    var $en = document.querySelector(".en");
    var $select = document.querySelector("select");

    // Changes at v1.8.1: include lang flag as a url query. This interop well with catalog hash anchors.
    function getLang() { return new URLSearchParams(document.location.search).get("lang") }

    function setLang(newLang) {
        var params = new URLSearchParams(document.location.search)
        params.set("lang", newLang)
        document.location.search = params.toString()  // refresh.
    }

    // handle render
    function _render() {
        var lang = getLang()
        // en
        if (lang == "en") {
            $select.selectedIndex = 1;
            $en.style.display = "block";
            $en.classList.add("active");
            $zh.style.display = "none";
            $zh.classList.remove("active");
            // default to zh-cn
        } else {
            $select.selectedIndex = 0;
            $zh.style.display = "block";
            $zh.classList.add("active");
            $en.style.display = "none";
            $en.classList.remove("active");
        }
        // interop with catalog 
        generateCatalog(".catalog-body");
    }

    // handle select change
    function onLanChange(index) {
        if (index == 0) {
            lang = "zh"
        } else {
            lang = "en"
        }
        setLang(lang)
    }

    // init
    _render();
</script>
{{ end }}

{{ if or .Page.Params.plantuml .Site.Params.plantuml }}
<!-- PlantUML -->
<script src="https://cdn.jsdelivr.net/gh/jmnote/plantuml-encoder@1.2.4/dist/plantuml-encoder.min.js" integrity="sha256-Qsk2KRBCN5qVZX7B+8+2IvQl1Aqc723qV1tBCQaVoqo=" crossorigin="anonymous"></script>
<script>
(function(){
  let plantumlPrefix = "language-plantuml";
  Array.prototype.forEach.call(document.querySelectorAll("[class^=" + plantumlPrefix + "]"), function(code){
    let image = document.createElement("IMG");
    image.loading = 'lazy'; // Lazy loading
    image.src = 'http://www.plantuml.com/plantuml/svg/~1' + plantumlEncoder.encode(code.innerText);
    code.parentNode.parentNode.insertBefore(image, code.parentNode);
    code.parentNode.style.display = 'none';
  });
})();
</script>
{{ end }}
